package com.example.yan.java文件写入;
import java.io.*;
public class Main6 {

    public class Main {

        public  void main(String[] args) throws Exception {
            File temp = File.createTempFile("test", ".txt");
            System.out.println("文件路径: " + temp.getAbsolutePath());
            temp.deleteOnExit();
            BufferedWriter out = new BufferedWriter(new FileWriter(temp));
            out.write("aString");
            System.out.println("临时文件已创建:");
            out.close();
        }


       /* public static void main(String[] args) throws IOException, InterruptedException {
            File temp = File.createTempFile("test", ".txt");
            System.out.println("文件路径: "+temp.getAbsolutePath());
            temp.deleteOnExit();
            BufferedWriter out = new BufferedWriter(new FileWriter(temp));
            out.write("aString");
            out.flush();
            System.out.println("临时文件已创建:");
            Thread.sleep(10000);
            System.out.println("临时文件已删除");
            out.close();
        }*/
    }

}
